# -*- coding: UTF-8 -*-
from abc import ABCMeta, abstractmethod


class AbstractPortfolio(object):

    """
    Abstract class of Portfolio
    """
    __metaclass__ = ABCMeta


    @abstractmethod
    def transact_position(
            self, action, ticker,
            quantity, price, commission
    ):
        """
        处理position事务,增加或修改
        """
        raise NotImplementedError("Should implement transact_position()")


class AbstractPortfolioHandler(object):

    __metaclass__ = ABCMeta

    @abstractmethod
    def on_signal(self, signal_event):
        """
        抽象方法，处理买卖信号事件
        """
        raise NotImplementedError("Should implement on_signal()")

    @abstractmethod
    def on_fill(self, fill_event):
        """
        处理成交结果事件
        """
        raise NotImplementedError("Should implement on_fill()")

    @abstractmethod
    def update_portfolio_value(self):
        """
        当市场行情价格变化时候自动更新投资组合里面的参数
        """
        raise NotImplementedError("Should implement update_portfolio_value()")
